home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Frame;
- import java.awt.GridLayout;
- import java.awt.Insets;
- import java.awt.LayoutManager;
- import java.awt.TextArea;
- import java.awt.TextComponent;
- import java.awt.Toolkit;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.io.BufferedReader;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.EventObject;
-
- public class EnterBox extends Applet implements WindowListener, ActionListener {
- public String url;
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private String agreeText;
- private String disagreeText;
- private Dialog dialog;
- private int mode;
- private String text;
- private String file;
-
- public String getAppletInfo() {
- return "Name: EnterBox\r\nAuthor: Taiji Software\r\n";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var9) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- this.putComponents();
- }
-
- public void stop() {
- if (this.dialog != null && this.dialog.isShowing()) {
- this.dialog.dispose();
- }
-
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- this.agreeText = ((Applet)this).getParameter("button_agree_text");
- if (this.agreeText == null) {
- this.agreeText = "I agree";
- }
-
- this.disagreeText = ((Applet)this).getParameter("button_disagree_text");
- if (this.disagreeText == null) {
- this.disagreeText = "I don't agree";
- }
-
- ((Component)this).setBackground(this.getColor("background_color"));
- this.file = ((Applet)this).getParameter("file");
- }
-
- public Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public void putComponents() {
- String s = ((Applet)this).getParameter("frame_width");
- int dialogWidth;
- if (s != null) {
- dialogWidth = Integer.parseInt(s);
- } else {
- dialogWidth = 200;
- }
-
- s = ((Applet)this).getParameter("frame_height");
- int dialogHeight;
- if (s != null) {
- dialogHeight = Integer.parseInt(s);
- } else {
- dialogHeight = 200;
- }
-
- s = ((Applet)this).getParameter("mode");
- if (s != null) {
- this.mode = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("frame_title");
- if (s == null) {
- s = "Information";
- }
-
- Frame f = new Frame();
- this.dialog = new Dialog(f, s);
- this.dialog.setLayout((LayoutManager)null);
- this.dialog.addWindowListener(this);
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- int width = toolkit.getScreenSize().width;
- int height = toolkit.getScreenSize().height;
- if (((Applet)this).getParameter("frame_background_color") != null) {
- this.dialog.setBackground(this.getColor("frame_background_color"));
- } else {
- this.dialog.setBackground((new Button()).getBackground());
- }
-
- this.dialog.setVisible(true);
- this.dialog.setBounds((width - dialogWidth) / 2, (height - dialogHeight) / 2, dialogWidth, dialogHeight);
- Insets insets = this.dialog.getInsets();
- this.dialog.dispose();
- Button b1 = new Button(this.agreeText);
- Button b2 = new Button(this.disagreeText);
- ((Container)this).add(b1);
- ((Container)this).add(b2);
- int w = ((Component)b1).getPreferredSize().width;
- int w2 = ((Component)b2).getPreferredSize().width;
- if (w2 > w) {
- w = w2;
- }
-
- ((Container)this).remove(b1);
- ((Container)this).remove(b2);
- this.dialog.add(b1);
- this.dialog.add(b2);
- b1.addActionListener(this);
- b2.addActionListener(this);
- int space = (dialogWidth - 2 * w) / 3;
- ((Component)b1).setBounds(space, dialogHeight - 25 - insets.bottom - 20, w, 25);
- ((Component)b2).setBounds(2 * space + w, dialogHeight - 25 - insets.bottom - 20, w, 25);
- TextArea textarea = new TextArea();
- ((TextComponent)textarea).setEditable(false);
- this.dialog.add(textarea);
- ((Component)textarea).setBounds(10, insets.top + 20, dialogWidth - 20, ((Component)b1).getLocation().y - 20 - insets.top - 20);
-
- try {
- InputStream in = null;
- in = (new URL(((Applet)this).getCodeBase(), this.file)).openStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
-
- String s2;
- while((s2 = br.readLine()) != null) {
- textarea.append(s2 + "\r\n");
- }
-
- br.close();
- } catch (Exception ee) {
- System.err.println(ee);
- }
-
- s = ((Applet)this).getParameter("button_show_text");
- if (s == null) {
- s = "Enter !";
- }
-
- if (this.mode == 0) {
- Button showButton = new Button(s);
- showButton.addActionListener(this);
- ((Container)this).setLayout(new GridLayout(1, 1));
- ((Container)this).add(showButton);
- } else {
- this.dialog.show();
- System.out.println(dialogHeight);
- System.out.println(this.dialog.getSize().height);
- }
- }
-
- public void actionPerformed(ActionEvent event) {
- if (((EventObject)event).getSource() instanceof Button) {
- String s = ((Button)((EventObject)event).getSource()).getLabel();
- if (s.equals(this.agreeText)) {
- this.quitDialog(true);
- } else if (s.equals(this.disagreeText)) {
- this.quitDialog(false);
- } else {
- this.dialog.show();
- }
- }
- }
-
- public void quitDialog(boolean agree) {
- String link;
- if (agree) {
- link = ((Applet)this).getParameter("agree_link");
- } else {
- link = ((Applet)this).getParameter("disagree_link");
- }
-
- if (link != null) {
- String target = ((Applet)this).getParameter("target");
- if (target == null) {
- target = "_blank";
- }
-
- URL u = this.giveURL(link);
- ((Applet)this).getAppletContext().showDocument(u, target);
- }
-
- this.dialog.dispose();
- }
-
- public void windowClosing(WindowEvent e) {
- this.quitDialog(false);
- }
-
- public void windowClosed(WindowEvent e) {
- }
-
- public void windowOpened(WindowEvent e) {
- }
-
- public void windowIconified(WindowEvent e) {
- }
-
- public void windowDeiconified(WindowEvent e) {
- }
-
- public void windowActivated(WindowEvent e) {
- }
-
- public void windowDeactivated(WindowEvent e) {
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
- }
-